BUFF_FLASH_TIME_ON = 0.8;
BUFF_FLASH_TIME_OFF = 0.8;
BUFF_MIN_ALPHA = 0.70;

local tBuffs = CreateFrame("Frame");
local _G = getfenv(0);

tBuffs:SetScript("OnEvent", function()

	if event == "PLAYER_LOGIN" then
	
		TemporaryEnchantFrame:ClearAllPoints();
		TemporaryEnchantFrame:SetPoint("TOPRIGHT", Minimap, "TOPLEFT", -15, 0);
		TemporaryEnchantFrame.SetPoint = function() end;
		
		TicketStatusFrame:Hide();
		TicketStatusFrame.Show = function() end;
	
	elseif event == "PLAYER_AURAS_CHANGED" then
	
		local i;
		
		i = 1;
		while _G["BuffButton"..i] do 
			tBuffs:Update("BuffButton"..i, 1);
			i = i + 1;
		end
		
		i = 1;
		while _G["DebuffButton"..i] do
			tBuffs:Update("DebuffButton"..i, 2);
			i = i + 1;
		end
		
		i = 1
		while _G["TempEnchant"..i] do
			tBuffs:Update("TempEnchant"..i, 3);
			i = i + 1;
		end	
			
	end

end)

function tBuffs:Update(name, isDebuff)

	local b = _G[name.."Border"];
	local i = _G[name.."Icon"];
	local f = _G[name];
	local c = _G[name.."Gloss"];
	local ff = _G[name.."Duration"];

	if not c then
	
		local fg = CreateFrame("Frame", name.."Gloss", f);
		fg:SetAllPoints(f);
		
		local t = f:CreateTexture(nil, "ARTWORK");
		t:SetTexture("Interface\\AddOns\\tBuffs\\gloss");
		t:SetPoint("TOPLEFT", fg, "TOPLEFT", -0, 0);
		t:SetPoint("BOTTOMRIGHT", fg, "BOTTOMRIGHT", 0, -0);
		fg.texture = t;
		
		i:SetTexCoord(0.1, 0.9, 0.1, 0.9);
		i:SetPoint("TOPLEFT", fg, "TOPLEFT", 2, -2);
		i:SetPoint("BOTTOMRIGHT", fg, "BOTTOMRIGHT", -2, 2);
	
	end

	if b then b:Hide() end

end

tBuffs:RegisterEvent("PLAYER_AURAS_CHANGED");
tBuffs:RegisterEvent("PLAYER_LOGIN");